package com.syt.hospital.controller;

import com.syt.hospital.service.ScheduleService;
import com.syt.model.hospital.Schedule;
import com.syt.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;


/**
 * @Author: xxx
 * @Date: 2023/2/16 21:03
 * @Description: 医院排班
 */
@Api(tags = "医院排班")
@RestController
@RequestMapping("/admin/hospital/schedule")
//@CrossOrigin 有 gateway 做了跨域
public class ScheduleController {

    @Autowired
    private ScheduleService scheduleService;


    //根据医院编号、科室编号和工作日期，查询排班详细信息
    @ApiOperation(value = "查询排班详细信息")
    @GetMapping("/getScheduleDetails/{hoscode}/{depcode}/{workDate}")
    public Result getDetailsSchedule(@PathVariable String hoscode,
                                     @PathVariable String depcode,
                                     @PathVariable String workDate){
             List<Schedule> list= scheduleService.getScheduleDetails(hoscode, depcode, workDate);
             return Result.ok(list);
    }


    //根据医院编号和科室编号，查询医院排班规则数据
    @ApiOperation(value = "查询医院排班规则数据")
    @GetMapping("/getScheduleRule/{page}/{limit}/{hoscode}/{depcode}")
    public Result getScheduleRule(@PathVariable int page,
                                  @PathVariable int limit,
                                  @PathVariable String hoscode,
                                  @PathVariable String depcode){
        Map<String,Object> map=scheduleService.getScheduleRule(page, limit,hoscode,depcode);
        return Result.ok(map);
    }
}
